package 校招笔试.美团笔试.美23819;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/8/20 14:11
 */
public class Main {
    /*
     题目的链接 直接用塔子哥的吧 , 至少还能评测!
     https://codefun2000.com/p?q=category%3A%E7%BE%8E%E5%9B%A2
     */

    static Scanner sc = new Scanner(System.in);


    public static void main1(String[] args) {
        int q = sc.nextInt();
        while (q-- >= 0) {
            int m = sc.nextInt(), x = sc.nextInt();

            if (m < x) {
                System.out.println(x % m);
            } else {
                System.out.println(x);
            }


        }


    }

    public static void main2(String[] args) {
        int n = sc.nextInt();
        int nums[] = new int[n];

        for (int i = 0; i < nums.length; i++) {
            nums[i] = sc.nextInt();
        }

        long sum = nums[0], max = 0, sum_m = 0;

        for (int i = 1; i < n; i++) {
            sum += nums[i];
            if (nums[i] * nums[i - 1] > max) {
                max = nums[i] * nums[i - 1];
                sum_m = nums[i] + nums[i - 1];
            }
        }
        System.out.println(sum + max - sum_m);
    }


    // 这个题 直接 暴力 骗分 ,  就两种情况 10101010  或者 01010101
    // 这个题 还是有点意思的!
    public static void main3(String[] args) {
        String s = sc.nextLine();
        char[] str = s.toCharArray();
        int preSum0[] = new int[s.length() + 1]; // 0101010
        int preSum1[] = new int[s.length() + 1]; //10101010
        for(int i = 0;i < str.length;i++){
//            int temp = i % 2;
            if(i % 2 == 0){ // 偶数位
                preSum0[i+ 1] = preSum0[i]  + (str[i] == '0' ? 0 : 1);
                preSum1[i+ 1] = preSum1[i]  + (str[i] == '0' ? 1 : 0);
            }else{ // 奇数位
                preSum0[i+ 1] = preSum0[i]  + (str[i] == '0' ? 1 : 0);
                preSum1[i+ 1] = preSum1[i]  + (str[i] == '0' ? 0 : 1);
            }
        }

        int ans = 0;
        for(int i = 0;i < str.length;i++ ){
            for(int j = i + 1; j < str.length;j++){
                ans += Math.min(preSum0[j + 1] - preSum0[i], preSum1[j + 1] - preSum1[i]);
            }
        }
//        System.out.println(Arrays.toString(preSum));
        System.out.println(ans);
    }

    //dp
    public static void main(String[] args) {
        int n = sc.nextInt();
        int nums[] = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
            sum += nums[i];
        }
        int ans = recursion(0, sum, nums, new Integer[n + 1][sum + 1]);
        System.out.println(ans);
    }

    public static int recursion(int index, int rest, int nums[], Integer dp[][]) {
        if (index == nums.length) {
            return rest == 0 ? 1 : 0;
        }
        if (dp[index][rest] != null) {
            return dp[index][rest];
        }
        long ans = 0;
        for (int i = 1; i <= rest; i++) {
            if (i != nums[index]) {
                ans += recursion(index + 1, rest - i, nums, dp);
            }
        }
        int temp = (int) (ans % 1000000007);
        return dp[index][rest] = temp;
    }


    //最后一道题 妈的 观察题， 这种题 想出来就想出来了， 想不出来就想不出来了！


}
